package com.itheima.d15_api_StringBuilder;

import com.sun.tools.javac.Main;

public class Test3 {
    public static void main(String[] args) {
        //完成遍历数组内容
        int[] arr = {1, 2, 3};
        System.out.println(getArrayData(arr));

    }

    public static String getArrayData(int[] arr) {
        if (arr == null) {
            return null;
        }
        StringBuilder sb = new StringBuilder();
        sb.append("[");
        for (int i = 0; i < arr.length; i++) {

            if (i != arr.length - 1) {
                sb.append(arr[i]+",");
            } else {
                sb.append(arr[i]+"]");
            }
        }

        return sb.toString();
    }
}
